<?php
namespace  Api\Controller;
use       Think\Controller;
class AjaxController extends Controller{
	/**
	 * 项目编号列表
	 */
	public function get_projectlist_sel_js(){
	
		$project_keyword = I('project_keyword');
		if(!empty($project_keyword)){
			$condition = array('like','%'.$project_keyword.'%');
			$map['id|project_name|project_number'] = array($condition,$condition,$condition,'_multi'=>true);
		}else{
			$project_map_json=I('project_map_json');
			$map=$project_map_json;
		}
		$id=I("id");
	
			
		$list=M('Project')->where($map)->order("create_time desc")->select();
		foreach ($list as $k => $vo) {
	
			if($vo['id']==$id){
				$data .= "<option value ='" . $vo['id'] . "' selected>" . $vo['project_number']. "</option>";
			}else{
				$data .= "<option value ='" . $vo['id'] . "'>" . $vo['project_number']."</option>";
			}
	
		}
		$this->ajaxReturn($data);
	}
	
	//客户列表
	public function get_userlist_sel_js(){
	
		$user_keyword = I('user_keyword');
		if(!empty($user_keyword)){
			$condition = array('like','%'.$user_keyword.'%');
			$map['id|customer_name|customer_num|mobile'] = array($condition,$condition,$condition, $condition,'_multi'=>true);
		}else{
			$user_map_json=I('user_map_json');
			$map=$user_map_json;
		}
	  $id=I("id");
	 
		$map['status']=1;
		 
		$list=M('Customer')->where($map)->order("create_time desc")->limit(10)->select();
		foreach ($list as $k => $vo) {

				 if($vo['id']==$id){
			 	$data .= "<option value ='" . $vo['id'] . "' selected>" . $vo['customer_name']. "</option>";
			 }else{
			 	$data .= "<option value ='" . $vo['id'] . "'>" . $vo['customer_name']."</option>";
			 }

		}
		$this->ajaxReturn($data);
	}
//服务器列表	
	public function get_serverlist_sel_js(){
	
		$server_keyword = I('server_keyword');
		if(!empty($server_keyword)){
			$condition = array('like','%'.$server_keyword.'%');
			$map['id|server_name'] = array($condition,$condition,'_multi'=>true);
		}else{
			$server_map_json=I('server_map_json');
			$map=$server_map_json;
		}
	  $serverid=I("serverid");
	 
		$map['status']=1;
		 
		$list=M('Server')->where($map)->select();
		foreach ($list as $k => $vo) {
	 
				 if($vo['id']==$serverid){
			 	$data .= "<option value ='" . $vo['id'] . "' selected>" . $vo['server_name']. "</option>";
			 }else{
			 	$data .= "<option value ='" . $vo['id'] . "'>" . $vo['server_name']."</option>";
			 }

			
		}
		$this->ajaxReturn($data);
	}
//数据库列表
	public function get_databaselist_sel_js(){
	
		$database_keyword = I('database_keyword');
		if(!empty($database_keyword)){
			$condition = array('like','%'.$database_keyword.'%');
			$map['id|name'] = array($condition,$condition,'_multi'=>true);
		}else{
			$database_map_json=I('database_map_json');
			$map=$database_map_json;
		}
	  $databaseid=I("databaseid");
	 
		$map['status']=1;
		 
		$list=M('Database')->where($map)->select();
		foreach ($list as $k => $vo) {
	 
				 if($vo['id']==$databaseid){
			 	$data .= "<option value ='" . $vo['id'] . "' selected>" . $vo['name']. "</option>";
			 }else{
			 	$data .= "<option value ='" . $vo['id'] . "'>" . $vo['name']."</option>";
			 }

			
		}
		$this->ajaxReturn($data);
	}
//域名列表
	public function get_domainlist_sel_js(){
	
		$domain_keyword = I('domain_keyword');
		if(!empty($domain_keyword)){
			$condition = array('like','%'.$domain_keyword.'%');
			$map['id|name'] = array($condition,$condition,'_multi'=>true);
		}else{
			$domain_map_json=I('domain_map_json');
			$map=$domain_map_json;
		}
	  $domainid=I("domainid");
	 
		$map['status']=1;
		 
		$list=M('Domain')->where($map)->select();
		foreach ($list as $k => $vo) {
	 
				 if($vo['id']==$domainid){
			 	$data .= "<option value ='" . $vo['id'] . "' selected>" . $vo['name']. "</option>";
			 }else{
			 	$data .= "<option value ='" . $vo['id'] . "'>" . $vo['name']."</option>";
			 }

			
		}
		$this->ajaxReturn($data);
	}	
//主机列表
	public function get_masterlist_sel_js(){
	
		$master_keyword = I('master_keyword');
		if(!empty($master_keyword)){
			$condition = array('like','%'.$master_keyword.'%');
			$map['id|name'] = array($condition,$condition,'_multi'=>true);
		}else{
			$master_map_json=I('master_map_json');
			$map=$master_map_json;
		}
	  $masterid=I("masterid");
	 
		$map['status']=1;
		 
		$list=M('Master')->where($map)->select();
		foreach ($list as $k => $vo) {
	 
				 if($vo['id']==$masterid){
			 	$data .= "<option value ='" . $vo['id'] . "' selected>" . $vo['name']. "</option>";
			 }else{
			 	$data .= "<option value ='" . $vo['id'] . "'>" . $vo['name']."</option>";
			 }

			
		}
		$this->ajaxReturn($data);
	}	
	
	//网站列表
	public function get_websitelist_sel_js(){
	
		$website_keyword = I('website_keyword');
		if(!empty($website_keyword)){
			$condition = array('like','%'.$website_keyword.'%');
			$map['id|name'] = array($condition,$condition,'_multi'=>true);
		}else{
			$website_map_json=I('website_map_json');
			$map=$website_map_json;
		}
	  $websiteid=I("websiteid");
	 
		$map['status']=1;
		 
		$list=M('Website')->where($map)->select();
		foreach ($list as $k => $vo) {
	 
				 if($vo['id']==$websiteid){
			 	$data .= "<option value ='" . $vo['id'] . "' selected>" . $vo['name']. "</option>";
			 }else{
			 	$data .= "<option value ='" . $vo['id'] . "'>" . $vo['name']."</option>";
			 }

			
		}
		$this->ajaxReturn($data);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
?>